<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<%@include file="../common/mastertopedit.jsp"%>
<script type="text/javascript" src="${ctx}/js/region.js"></script>
<input type="hidden" id="shopId" value="${model.shopInfo.id}">
<div class="form-horizontal pt-15  form-clean-magin" id="content">
	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">门店编码</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				id="shopCode" placeholder="店铺编码" value="${model.shopInfo.shopCode}">
			<i class="plum-sign-right">*</i>
		</div>
	</div>

	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">门店名称</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" id="shopName"
				type="text" value="${model.shopInfo.shopName}"> <i
				class="plum-sign-right">*</i>
		</div>
	</div>
	
	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">地址</label>
		<div class="col-xs-9">
			<input type="hidden" id="pid" value="${model.shopInfo.provinceId}">
			<input type="hidden" id="cid" value="${model.shopInfo.cityId}">
			<input type="hidden" id="aid" value="${model.shopInfo.areaId}">
			<select id="provinceId" class="form-control form-control-125 pull-left"   onchange="selectProvince()" >
				<option value="" >选择市</option>
			</select>
			<select id="cityId" class="form-control form-control-125 pull-left" onchange="selectCity()" >
				<option value="" >选择市</option>
			</select>
			<select id="areaId" class="form-control form-control-125 pull-left"  >
				<option value="" >选择市</option>
			</select>
		</div>
	</div>
	
	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">详细地址</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				name="address" id="address" maxlength="100" type="text"
				value="${model.shopInfo.address}"> 
		</div>
	</div>
	
	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">店长姓名</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				name="contactName" id="contactName" maxlength="100" type="text"
				value="${model.shopInfo.contactName}"> 
		</div>
	</div>
	
		<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">联系电话</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				name="contactMobile" id="contactMobile" maxlength="100" type="text"
				value="${model.shopInfo.contactMobile}"> 
		</div>
	</div>
	



</div>
<div class="form-group text-center">
	<button type="button" class="runmi-btn runmi-primary"
		onclick="backIndex()">取消</button>
	<button type="button" class="runmi-btn runmi-sure-btn" onclick="save()">保存</button>
</div>

<script type="text/javascript">
	function save() {
		var postData = "&shopId=" + $('#shopId').val();

		var shopCode = $('#shopCode').val();
		if (shopCode == '') {
			layer.alert('请输入门店编码');
			return;
		}
		postData = postData + "&shopCode=" + encodeURIComponent(shopCode);


		var shopName = $('#shopName').val();
		if (shopName == '') {
			layer.alert('请输入门店名称');
			return;
		}
		postData = postData + "&shopName=" + encodeURIComponent(shopName);

		var provinceId=$('#provinceId').val();
		postData=postData + "&provinceId=" + encodeURIComponent(provinceId);
		
		var cityId=$('#cityId').val();
		postData=postData + "&cityId=" + encodeURIComponent(cityId);
		
		var areaId=$('#areaId').val();
		postData=postData + "&areaId=" + encodeURIComponent(areaId);
		
		var address=$('#address').val();
		postData=postData + "&address=" + encodeURIComponent(address);
		
		var contactName=$('#contactName').val();
		postData=postData + "&contactName=" + encodeURIComponent(contactName);
		
		var contactMobile=$('#contactMobile').val();
		postData=postData + "&contactMobile=" + encodeURIComponent(contactMobile);

	
		layer.load(1, {
			shade : [ 0.5, '#fff' ]
		});
		//alert(postData);
		$.ajax({
			type : "POST",
			url : "saveShop",
			data : postData,
			contentType : "application/x-www-form-urlencoded;charset=UTF-8",
			async : true, // 同步  true 异步。默认是异步
			dataType : 'json',
			error : function(resultdata) {
				layer.closeAll();
			},
			success : function(resultdata) {
				layer.closeAll();
				if (resultdata.returnCode == "0000") {
					layer.alert('操作成功', {
						icon : 1
					}, function() {
						parent.editReturn();
						//layer.closeAll(); 
						//layer.closeAll();
						//window.location.href="${pageContext.request.contextPath}/distrbutor/inventory/index";
					});
				} else {
					layer.alert(resultdata.returnMessage);
				}
			}
		});
	}
	function backIndex() {
		parent.editReturn();
	}
</script>
<%@include file="../common/masterbottom.jsp"%>
